<template>
  <div class="app-container">
    <ListPage :details-func="detailsFunc" :model-name="modelName" />
  </div>
</template>

<script>
import ListPage from '@/selfComponents/ListPage'
import odoo from '@/odooapi'
const modelName = 'Test/HrEmployee'

export default {
  name: 'Employee',
  components: { ListPage },
  directives: {},
  filters: {},

  data() {
    return {
      modelName: modelName
    }
  },
  async created() {},
  methods: {
    detailsFunc(row) {
      this.$confirm('此操作将重置该用户的密码为初始密码, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // console.log(cc)
          const { user_id } = row
          odoo
            .env('res.users')
            .write({ id: user_id, password: '111111' })
            .then(res => {
              if (res) {
                this.$message({
                  type: 'success',
                  message: '重置成功!'
                })
              } else {
                this.$message({
                  type: 'error',
                  message: '重置失败!'
                })
              }
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消重置'
          })
        })
    }
  }
}
</script>
